/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.shephertz.appwarp.websocket.binary;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

/**
 * Codec Factory used for creating websocket filter.<br>
 * by 张勇: 完成了简化并增强版的 Mina WebSocket 编解码器，实测单个数据包可以达到120KB以上！<br>
 * by 张勇: 解决了原实现代码中不支持文本消息的问题，现在可以同时支持二进制和文本数据！（不过浏览器端的WebSocket似乎只能处理文本数据？）<br>
 * @see <a href='https://issues.apache.org/jira/browse/DIRMINA-907'>DIRMINA-907</a><br>
 * @author DHRUV CHOPRA/张勇
 */
public class WebSocketCodecFactory implements ProtocolCodecFactory{
    private ProtocolEncoder encoder;
    private ProtocolDecoder decoder;

    public WebSocketCodecFactory() {
            encoder = new WebSocketEncoder();
            decoder = new WebSocketDecoder();
    }

    @Override
    public ProtocolEncoder getEncoder(IoSession ioSession) throws Exception {
        return encoder;
    }

    @Override
    public ProtocolDecoder getDecoder(IoSession ioSession) throws Exception {
        return decoder;
    }
}
